/**
 * Created by qintao30057 on 2017/3/13.
 */

$(function () {

})

function doOnFormInit2() {
    if(typeof(editForm2) != 'object') return;
    editForm2.setReadonly('functionName',true);
    editForm2.setReadonly('telephone',true);
    editForm2.setReadonly('content',true);
    editForm2.setItemValue("functionName",parent.oneSQInfo.function_name);
    editForm2.setItemValue("telephone",parent.oneSQInfo.telephone);
    editForm2.setItemValue("content",parent.oneSQInfo.content);
}

function doOnFormInit1() {
    if(typeof(editForm1) != 'object') return;

    $(editForm1.getInput("disposeResult")).attr("maxlength",500);

    var disposeWay_combo = editForm1.getCombo("disposeWay");
    disposeWay_combo.addOption(parent.disposeWayComboData);
    disposeWay_combo.setComboValue('');
    disposeWay_combo.readonly(true);
}

function doOnButtonForm() {
    if (typeof(buttonForm) != 'object') return;

    buttonForm.attachEvent("onButtonClick", function(name, command) {
        switch(command) {
            case 'save':doSave();break;
            case 'cancle':doCancle();break;
        }
    });
}

function doCancle() {
    parent.disposeWin.close();
}

function doSave() {
    var postData = "id="+parent.oneSQInfo.id;
    if (typeof(editForm1) == 'object') {
        var disposeWay = $.trim(editForm1.getItemValue("disposeWay"));
        if (disposeWay != '') {
            postData += "&disposeWay=" + disposeWay;
        }
        var disposeResult = $.trim(editForm1.getInput("disposeResult").value);
        if (disposeResult != '') {
            postData += "&disposeResult=" + disposeResult;
        }
    }

    var dispose_status = $("input[name='isSolve']:checked").val();
    if (!dispose_status || dispose_status == '') {
        $func.alert("请先选择解决结果");
        return;
    }
    postData += "&disposeStatus=" + dispose_status;

    var url = basePath + "serviceQuestion/handleServiceQuestion";
    $.ajax({
        url: url,
        type: 'post',
        dataType: 'json',
        data: postData,
        success: function (back) {
            if (!back) {
                $func.alert("提交失败","red");
                return;
            }
            if(!back.result){
                $func.alert("提交失败，" + back.message, "red");
                return;
            }
            $func.alert("提交成功！", "green");
            parent.doRefresh();
            doCancle();
        }
    });
}